
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>广告位置管理</title>
    #include("../../common/res.html")
    <link rel="stylesheet" href="#(ctx)/static/ztree/css/zTreeStyle/zTreeStyle.css">
    <script type="text/javascript" src="#(ctx)/static/ztree/js/jquery.ztree.core-3.5.min.js"></script>
	<script type="text/javascript" src="#(ctx)/static/ztree/js/jquery.ztree.excheck-3.5.min.js"></script>
	<script type="text/javascript" src="#(ctx)/static/ztree/js/jquery.ztree.exedit-3.5.min.js"></script>
	<style>
	body{
		background:#fff;
	}
	.button{
		margin-bottom:10px;
	}
	</style>
</head> 
<body>
<div class="left">
	<ul id="treeDemo" class="ztree"></ul>
</div>
<div class="actions" style="margin-left: 250px;margin-top: 10px;">
	
	#button({btnId:"btn_saveOrder",className:"button button-uppercase button-primary",btnValue:"保存"})
</div>
<script>

$(function(){
	
	$("#btn_saveOrder").click(function(){
		//alert("sadf");
		$("#btn_saveOrder").attr("disabled","disabled");
		var nodes = zTree_Menu.getCheckedNodes(true);
		var selectIds="";
		for(var index in nodes){
			var item=nodes[index];
			if(item.id=='10000')continue;
			selectIds+=item.id+",";
		} 
		
		var submitData={
				"roleIds":selectIds,
				"id":"#(item.id)",
		}
		$.post("#(ctx)/admin/user/saveUserRoles" , submitData , 
			function(data){
			$("#btn_saveOrder").removeAttr("disabled");
			if(data.code==0){
				layer.msg('操作成功', {
				    icon: 1,
				    time: 2000 //2秒关闭（如果不配置，默认是3秒）
				},function(){
					parent.reloadGrid();
					var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index); //再执行关闭 
				});
			}else{
				layer.msg(data.msg, {
				    icon: 2,
				    time: 2000 //2秒关闭（如果不配置，默认是3秒）
				},function(){});
			}
		},"json");
	});
	resize();
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	zTree_Menu = $.fn.zTree.getZTreeObj("treeDemo");
	
	$(window).resize(function(){
		resize();
	});
	function resize(){
		h = $(window).height(),
		th = $("#top").outerHeight(true),
		mh = $(".main-title h3").outerHeight(true); 
		$(".left").height(h - th - mh- 55);
	}
	
	
});
var setting = {
		check: {
			enable: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeCheck: beforeCheck,
			onCheck: onCheck
		}
	};
function beforeCheck(treeId, treeNode) {
	return (treeNode.doCheck !== false);
}
function onCheck(e, treeId, treeNode) {

}
	var log, className = "dark";
	var zNodes =#(jsonTree.data);
	setting.check.chkboxType = { "Y" : "ps", "N" : "ps" };
</script>
</body> 
</html>